Attribute VB_Name = "CWI_BOM_Format"
Sub BOM_Format()
    
    Selection.ClearFormats
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$A1=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.399945066682943
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    
    i = 2
    While Cells(i, 1) <> ""
        If Cells(i, 1) = 2 Then
            j = i + 1
            While Cells(j, 1) = 2
                j = j + 1
            Wend
            j = j - 1
            Rows(i & ":" & j).Select
            Selection.Rows.Group
            i = j
        End If
        i = i + 1
    Wend
    Columns("A:A").Select
    Selection.EntireColumn.Hidden = True
    ActiveSheet.Outline.ShowLevels RowLevels:=1
    Range("B2").Select
End Sub
